package com.example.usermanager.service;

import com.example.usermanager.mapper.UserMapper;
import com.example.usermanager.model.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 郝文雪
 * @date 2022/8/6 11:10
 * @Description Test
 */
@Service
public class UserService {
    @Resource
    private UserMapper userMapper;

    public UserInfo login(String loginname,String password){
        return userMapper.login(loginname,password);
    }

    public List<UserInfo> getAll(){
        return userMapper.getAll();
    }

    public int add(UserInfo userInfo){
        return userMapper.add(userInfo);
    }

    public UserInfo getUserByLoginName(String loginname){
        return userMapper.getUserByLoginName(loginname);
    }

    public UserInfo getUserByUid(Integer uid){
        return userMapper.getUserByUid(uid);
    }

    public int updateUser(UserInfo userInfo){
        return userMapper.updateUser(userInfo);
    }

    public int delUser(Integer uid){
        return userMapper.delUser(uid);
    }

    public int delByIds(List<Integer> ids){
        return userMapper.delByIds(ids);
    }

    public List<UserInfo> getListByPage(String username,
                                        String address,
                                        String email,
                                        Integer limit,
                                        Integer offset){
        return userMapper.getListByPage(username,address,email,limit,offset);
    }

    public int totalCount(String username,
                          String address,
                          String email){
        return userMapper.totalCount(username,address,email);
    }
}
